﻿
function init() {
    if ($.getPara('themetypeid').toString() != '') {
        initexttype();
     }

    $('#save').bind('click', function () { save(); });


}




//保存
function save() {
    if ($('#SUBJ_CLASS_NAME').val() == '') {
        alert(lang.theme_can_not_be_empty);
        return;
    }

    $.ajaxHandler({
        url: App_Config.TadongUrl + "/AjaxMappingHandler.aspx",
        urlType: "themeTypeAdd",
        model: function () {
            var obj = {};
            obj.SUBJ_CLASS_NAME = $('#SUBJ_CLASS_NAME').val();
            obj.SUBJ_CLASS_ID = $('#SUBJ_CLASS_ID').val();

            return $.toJSON(obj);
        },
        success: function (data) {
            if (data) {
                alert(lang.add_new_theme_success);
                parent.theme_typeList.search();
                parent.$.closePage();

            }
        }
    });
   
}
//编辑初始化
function initexttype() {
    $.ajaxHandler({
        url: App_Config.TadongUrl + "/AjaxMappingHandler.aspx",
        urlType: "getThemeClassById",
        model: function () { return $.getPara('themetypeid').toString(); },
        success: function (data) {
            if (data) {
                for (var key in data) {
                    if ($('#' + key).length > 0) {
                        if (key == "SUBJ_CLASS_NAME")
                            $('#' + key).val(data[key]);
                        if (key == "SUBJ_CLASS_ID")
                            $('#' + key).val(data[key]);
                    }
                }
            }
        }
    });

  
}
function exit() {
    parent.$.closePage();
}